<?php
/**
 * Formulário padrão
 */
class App_Form_Usuario extends Voitech_Form
{
	public function __construct($options=array())
	{
		parent::__construct($options);
		
		$this->setAttribs(array('name'=>'frmCadastroUsuario', 'id'=>'frmCadastroUsuario', 'class'=>'form last-child'));
		                
		$obPessoaRepository = new App_Model_PessoaRepository();
                $arObPessoa = $obPessoaRepository->listarTodos(array('st_ativo'=>'S'));
                $selectBox = new Zend_Form_Element_Select( 'co_pessoa' );
                $selectBox->setLabel('Pessoa:');
                $selectBox->setAttribs( array('class'=> 'last-child' ) );
                $selectBox->setDecorators( $this->_decoratorDefault );
                $selectBox->addMultiOptions( Voitech_Util::converteModeloArrayCombo($arObPessoa
                                            , 'CoPessoa', 'NoPessoa')  );
                $selectBox->addFilters( array('StringTrim','StripTags') );
                $this->addElement( $selectBox );
                
                
		$noUsuario 	= new Zend_Form_Element_Text( 'no_usuario' );
		$noUsuario->setLabel( 'Usuário:' )
				 ->setAttribs( array('size'=>'55') )
                                 ->addFilter( new Zend_Filter_StringTrim() )
				 ->addValidator( new Zend_Validate_StringLength( array( 'min'=>'4', 'max'=>'155' ) ) )
                                 ->setDecorators( $this->_decoratorDefault )
				 ->setRequired( true );
		$this->addElement( $noUsuario );					
                
                $dsSenha = new Zend_Form_Element_Password( 'ds_senha' );
		$dsSenha->setLabel( 'Senha:' )
                       ->addFilter( new Zend_Filter_StringTrim() )
                       ->addFilter( new Zend_Filter_Alnum() )
                       ->addValidator( new Zend_Validate_Alnum() )
                       ->setDecorators( $this->_decoratorDefault );
		$this->addElement( $dsSenha );
	
                $buttonCancelar = new Zend_Form_Element_Button('Cancelar');
		$buttonCancelar->setAttribs( array('class'=> 'first-child last-child','style'=>'float:left;margin-top: 17px', 'id' => 'btnCancelar' ) )
		           ->removeDecorator( 'label' );
		$this->addElement( $buttonCancelar );

		$buttonCdst = new Zend_Form_Element_Button('Salvar');
		$buttonCdst->setAttribs( array('class'=> 'first-child last-child','style'=>'float:right; margin-top: 17px', 'id' => 'btnSalvar' ) )
		           ->removeDecorator( 'label' );
		
		$this->addElement( $buttonCdst );		
		$this->addDisplayGroup(array('co_pessoa','no_usuario','ds_senha','Cancelar','Salvar'),'Cadastro',array('legend' => 'Formulario de cadastro de usuario', 'class'=>'grey-bg first-child last-child fieldset-with-legend fieldset-with-legend-first-child'));
	}
}